<script lang="ts" setup>
import Header from '@/components/Header/index.vue'
import Footer from '@/components/Footer/index.vue'
import Tabbar from '@/components/Tabbar/index.vue'
import { ref } from 'vue'
const currentTabbarIndex = ref(0)
const productList = ref([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
const tabs = ref([
  {
    title: '全部商品',
    name: 'all',
  },
  {
    title: '内存',
    name: 'cache',
  },
])
const handleTabChange = (index: number) => {
  currentTabbarIndex.value = index
}
</script>
<template>
  <Header />
  <div class="store-container">
    <div class="store-wrapper">
      <div class="store-info">
        <div class="left-entry">
          <div class="store-img">
            <img src="/src/assets/pre.jpg" alt="" />
          </div>
          <div class="store-introduce">
            <div class="store-name">SanDisk闪迪旗舰店</div>
            <div class="store-fans">65粉丝</div>
            <div class="store-score">
              <div class="score-item">
                <div class="score-title">描述相符</div>
                <div class="score-value">4.8</div>
              </div>
              <div class="score-item">
                <div class="score-title">描述相符</div>
                <div class="score-value">4.8</div>
              </div>
            </div>
          </div>
        </div>
        <div class="right-entry">
          <div class="operation-container">
            <div class="operation-item">关注店铺</div>
            <div class="operation-item">联系客服</div>
          </div>
        </div>
      </div>
      <div class="store-product-container">
        <Tabbar :tabs="tabs" @tab-change="handleTabChange">
          <template v-slot:[tab.name] v-for="(tab, index) in tabs" :key="index">
            <div class="filter-container" v-if="currentTabbarIndex === index">
              <div class="filter-item">综合排序</div>
              <div class="filter-item">销量</div>
              <div class="filter-item">价格</div>
              <div class="filter-item">筛选</div>
            </div>
          </template>
        </Tabbar>
        <div class="product-list">
          <div
            :class="['product-item-wrap', 'default']"
            v-for="(item, index) in productList"
            :key="index"
          >
            <div class="product-item">
              <div class="product-img">
                <img src="../../assets/vue.svg" alt="" />
              </div>
              <div class="product-info">
                <div class="info-title-wrapper">
                  <div class="info-title">
                    大疆 DJI Avata/FPV 航拍机 无人机 高清航拍 二手无人机 大疆
                    Avata 探索套装
                  </div>
                </div>
                <div class="tag-list">
                  <div class="tag-text">大疆</div>
                  <div class="tag-text">无人机</div>
                  <div class="tag-text">送运费险</div>
                  <div class="tag-text">淘金币减3.9元</div>
                </div>
                <div class="price-wrapper">
                  <span class="price-unit">￥</span>
                  <span class="price-value">3479.00</span>
                  <span class="month-sale">69+人购买</span>
                </div>
                <div class="store-wrapper">
                  <div class="store-name">大疆官方旗舰店</div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <Footer />
</template>
<style lang="less" scoped>
.store-container {
  display: flex;
  padding: 20px 0;
  justify-content: center;
  background-color: #d9d9d9;
}
.store-wrapper {
  width: 1296px;
  border-radius: 10px;
  overflow: hidden;
  flex-direction: column;
}

.store-info {
  width: 100%;
  box-sizing: border-box;
  background-color: #fff;
  padding: 20px;
  display: flex;
  border-radius: 10px;
  .store-img {
    width: 100px;
    max-width: 100px;
    height: 100px;
    border-radius: 10px;
    overflow: hidden;
    margin-right: 20px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .left-entry {
    flex: 1;
    display: flex;
    .store-introduce {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
    }
    .store-name {
      font-size: 20px;
    }
    .store-score {
      display: flex;
    }
    .score-item {
      display: flex;
      font-size: 12px;
      margin-right: 5px;
      padding: 5px;
      border-radius: 5px;
      background-color: #e9e9e9;
      .score-value {
        margin-left: 5px;
      }
    }
  }
  .right-entry {
    width: 250px;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    .operation-container {
      display: flex;
      justify-content: center;
      .operation-item {
        width: 100px;
        height: 30px;
        border-radius: 5px;
        background-color: #fff;
        display: flex;
        justify-content: center;
        align-items: center;
        margin: 10px;
        cursor: pointer;
        border: 1px solid #e9e9e9;
      }
    }
  }
}
.store-product-container {
  margin-top: 20px;
  padding: 20px;
  border-radius: 10px;
  background-color: #fff;
}
.filter-container {
  display: flex;
  .filter-item {
    padding: 5px 10px;
    cursor: pointer;
  }
}

.product-list {
  display: flex;
  flex-wrap: wrap;
}

.product-item-wrap.default {
  box-sizing: border-box;
  padding: 10px;
  width: 20%;
  .product-item {
    padding: 10px;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s;
    &:hover {
      transform: translateY(-5px);
      box-shadow: @shadow-color;
    }
  }
  .product-img {
    width: 100%;
    height: 230px;
    border-radius: 10px;
    background-color: yellow;
    img {
      width: 100%;
      height: 100%;
      border-radius: 10px;
    }
  }
  .info-title {
    font-size: 14px;
    line-height: 20px;
    height: 40px;
    overflow: hidden;
    margin: 10px 0;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .tag-list {
    display: flex;
    box-sizing: border-box;
    padding: 0 2px;
  }
  .tag-text {
    color: #ff5000;
    font-size: 12px;
    &:not(:last-child) {
      margin-right: 5px;
    }
  }
  .price-wrapper {
    margin: 10px 0;
    display: flex;
    align-items: flex-end;
    flex-direction: row;
    height: 24px;
  }
  .price-unit,
  .price-value {
    color: #ff5000;
  }
  .price-unit {
    font-size: 14px;
    line-height: 14px;
    margin-bottom: 1px;
    margin-right: 2px;
  }
  .price-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 24px;
  }
  .month-sale {
    color: #50607a;
    font-size: 14px;
    line-height: 14px;
    margin-bottom: 1px;
    margin-left: 8px;
  }
  .store-wrapper {
    display: flex;
    cursor: pointer;
    .store-name {
      font-size: 12px;
      line-height: 18px;
    }
  }
}

@media screen and (max-width: 1276px) {
  .product-item-wrap.default {
    width: 25%;
  }
}

@media screen and (max-width: 1032px) {
  .product-item-wrap.default {
    width: 33.3%;
  }
}

@media screen and (max-width: 788px) {
  .product-item-wrap.default {
    width: 50%;
  }
}

@media screen and (max-width: 544px) {
  .product-item-wrap.default {
    width: 100%;
    padding: 0;
  }
}
</style>
